package com.itheima.mapper;

import com.itheima.domain.EmpQueryParam;
import com.itheima.domain.pojo.Emp;
import org.apache.ibatis.annotations.*;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;

@Mapper
public interface EmpMapper {
//    ===================传统查询=================
//    @Select("select count(*) from emp e left join dept d on e.dept_id = d.id")
//    public Long count();
//    @Select("select e.*,d.name deptName from emp e left join dept d on e.dept_id = d.id limit #{start},#{pageSize}")
//    List<Emp> list(Integer start, Integer pageSize);

//    ==================PageHelper=================

  //  @Select("select e.*,d.name deptName from emp e left join dept d on e.dept_id = d.id")
  //根据条件进行查找内容，用xml方式进行sql语句
    List<Emp> list(EmpQueryParam empQueryParam);

//添加emp的内容
  @Insert("insert into emp(username,name,gender,phone,job,salary,image,entry_date,dept_id,create_time,update_time)values (#{username},#{name},#{gender},#{phone},#{job},#{salary},#{image},#{entryDate},#{deptId},#{createTime},#{updateTime})")
  @Options(useGeneratedKeys = true,keyProperty = "id")
  void insert(Emp emp);

  void delete(List<Integer> ids);

  Emp get(Integer id);

  void updateById(Emp emp);


  @Select("select   id, username, password, name, gender, phone, job, salary, image, entry_date, dept_id, create_time, update_time from emp")
  List<Emp> lists();

  List<Map<String, Object>> empJobData();


  List<Map> empGenderData();

  List<Map> studentDegreeData();

  List<Map<String, Object>> studentCountData();

    Emp selectByUsernameAndPassword(@Param("username") String username , @Param("password") String password);
}
